/*
 * ConfigReader.java
 *
 * Created on 24 de Junho de 2007, 16:18
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package br.unifor.finance.presentation.webconfig;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 *
 * @author Leonardo
 */
public class WebConfigReader {
  
  String servletUrl = null;
  ResourceBundle resource =
          ResourceBundle.getBundle("br.unifor.finance.presentation.webconfig." +
          "WebConfig", Locale.ROOT);
  
  
  public WebConfigReader() {
    
  }
  
  public void setServletUrl(String servletUrl) {
    this.servletUrl = servletUrl;
  }
  
  public String getProperty(String key) {
    return resource.getString(key);
  }
  
  public String getClassProperty() {
    return resource.getString(servletUrl + ".class");
  }
  
  public String getDefaultMethodProperty() {
    return resource.getString(servletUrl + ".method");
  }
  
  public String getLayoutPathProperty() {
    return resource.getString(servletUrl + ".layout");
  }
  
  public String getInsertPagePathProperty() {
    return resource.getString(servletUrl + ".page");
  }
  
  public String getRedirectUrlProperty(String pattern) {
    return resource.getString(servletUrl + ".redirect." + pattern);
  }
  
  public boolean isValidated() {
    try {
      return ("true".equals(resource.getString(servletUrl + ".validate")));
    } catch (MissingResourceException mre) {
      return false;
    }
  }
}
